<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        #app {
            width: 100%;
            height: 100%;
            display: flex;
            justify-content: space-between;
        }

        .left {
            width: 500px;
            height: 500px;
            margin: 50px;
        }

        .content {
            width: 500px;
            height: 500px;
        }

        .content ul {
            width: 500px;
            list-style: none;
        }

        .content ul li {
            display: inline-block;
            width: 50px;
            height: 30px;
            line-height: 30px;
            margin: 0 10px;
            padding: 0 10px;
            margin-top: 10px;
            cursor: pointer;
            border: 1px solid #e38a0e;
        }

        .content button {
            width: 100px;
            height: 30px;
            border: none;
            background-color: #e38a0e;
            color: white;
            margin: 20px 10px;
        }


        .right {
            width: 600px;
            height: 500px;
            margin: 50px;
        }

        .active {
            background-color: #e38a0e;
            color: white;
        }
    </style>
</head>

<body>
    <div id="app">
        <div class="left">
            <div class="content">
                <ul>
                    <li v-for="(item,index) in list" :key="item.id" :class="{'active':item.isActive}"
                        @click="Active(item.id)">
                        <span v-model="size" @click="cl(item.id)">{{item.Szie}}</span>
                    </li>
                </ul>
                <button @click="flat">加入购物车</button>
            </div>
        </div>
        <div class="right">
            <div v-show="float">
                {{size}}
            </div>
        </div>
    </div>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <script>
        const { createApp } = Vue
        createApp({
            data() {
                return {
                    list: [
                        { id: 1, Szie: '150cm', isActive: false },
                        { id: 2, Szie: '160cm', isActive: false },
                        { id: 3, Szie: '170cm', isActive: false },
                        { id: 4, Szie: '180cm', isActive: false },
                        { id: 5, Szie: '190cm', isActive: false },
                        { id: 6, Szie: '200cm', isActive: false },
                        { id: 7, Szie: '210cm', isActive: false },
                    ],
                    size: '',
                    isActive: false,
                    float: false,
                }
            },
            methods: {
                cl(id) {
                    this.list.forEach(item => {
                        if (item.id === id) {
                            this.size = item.Szie
                        }
                    })
                },
                Active(id) {
                    this.list.forEach(item => {
                        item.isActive = false
                        if (item.id === id) {
                            item.isActive = true
                        }
                    })
                },
                flat() {
                    this.float = true
                }

            },

        }).mount('#app')
    </script>
</body>

</html>